package com.jjclub.beanStudy;

import javafx.fxml.Initializable;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import javax.security.auth.DestroyFailedException;
import javax.security.auth.Destroyable;
import java.net.URL;
import java.util.ResourceBundle;

/**
 * @Classname Book
 * @Description 使用
 * @Date 2019/10/29 11:40
 * @Created by jq
 */
@Component
//使用实现InitializingBean, DisposableBean接口的afterPropertiesSet和destroy方法实现初始化和销毁
public class Book implements InitializingBean, DisposableBean {


    private String name;
    private Integer price;

    public Book() {
        System.out.println("book...构造成功");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getPrice() {
        return price;
    }

    public void setPrice(Integer price) {
        this.price = price;
    }


    public void  init(){
        System.out.println("book...初始化");
    }
    public void destry(){
        System.out.println("book...销毁");
    }


    @Override
    public void destroy() throws Exception {
        System.out.println("接口销毁");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("接口初始化");
    }

}
